<template>

      <div class="table_review">
      <el-form :model="dataForm" :ref="dataForm">
       
      
      <div class="table_title td_color">审查意见表</div>
      <table class="table_wrap">
        <tbody>
          <tr>
            <td class="table_td td_color">
                客户经理
            </td>
            <td class="table_td">
              <el-input  v-model="dataForm.creatorName"/>
            </td>
            <td class="table_td td_color">
                业务类型
            </td>
            <td class="table_td">
              <DicSelect dictType = "抵押类型" :dictValue="dataForm.pledgeType" v-on:dictValue="dataForm.pledgeType=$event"/> 
            </td>
            <td class="table_td td_color">
                  还款方式
            </td>
            <td class="table_td">
              <DicSelect dictType = "还款方式" :dictValue="dataForm.repayMethod" v-on:dictValue="dataForm.repayMethod=$event"/>
            </td>
            <td class="table_td td_color">
                 年利率  
            </td>
            <td class="table_td">
               <el-input  v-model="dataForm.annualInterestRate"/>
            </td>
           
          </tr>
          <!--第二行-->
          <tr>
            <td class="table_td td_color">
                婚姻情况
            </td>
            <td colspan="2" class="table_td">
              <DicSelect dictType = "婚姻情况" :dictValue="dataForm.marriageStatus" v-on:dictValue="dataForm.marriageStatus=$event"/>
            </td>
            <td class="table_td td_color">
                电子邮箱
            </td>
            <td colspan="2" class="table_td">
              <el-input  v-model="dataForm.email"/>
            </td>
            <td class="table_td td_color">
                QQ/微信号
            </td>
            <td colspan="2" class="table_td">
              <el-input  v-model="dataForm.wechatNo"/>
            </td>
          <!--第三行-->
          <tr>
            <td class="table_td td_color">
                借款人
            </td>
            <td colspan="2" class="table_td">
              <el-input  v-model="dataForm.realName"/>
            </td>
            <td class="table_td td_color">
                身份证号
            </td>
            <td colspan="2" class="table_td">
              {{dataForm.idCardNo}}
              <!-- <el-input disabled v-model="dataForm.idCardNo"/> -->
            </td>
            <td class="table_td td_color">
                联系电话
            </td>
            <td colspan="2" class="table_td">
              <el-input  v-model="dataForm.mobile"/>
            </td>
          </tr>
          <!--第四行 —— 第八行-->
          <tr v-for="(item,index) in dataForm.reviewOwnerDTOS">
            <td class="table_td td_color">
                共款人{{index+1}}
            </td>
            <td colspan="2" class="table_td">
              <el-input  v-model="item.realName"/>                
            </td>
            <td class="table_td td_color">
                身份证号
            </td>
            <td colspan="2" class="table_td">
              {{item.idCardNo}}
              <!-- <el-input disabled  v-model="item.idCardNo"/>      -->
            </td>
            <td class="table_td td_color">
                联系电话
            </td>
            <td colspan="2" class="table_td">
              <el-input  v-model="item.mobile"/>     
            </td>
          </tr>
         

        </tbody>
      </table>

  <!--第二个表格 房产情况描述-->

         <table class="table_wrap" style="margin-top:10px;" v-if="dataForm.houseDTO!=undefined">
        <tbody>
          
          <!--第一行-->
          <tr>
            <td rowspan="6" class="table_td td_color"  style="font-size:13px;">
                房产情况描述
            </td>
            <td colspan="1" class="table_td td_color"  style="font-size:13px;">
                权利人/产权人
            </td>
            <td class="table_td">
              <el-input  v-model="dataForm.houseDTO.propertyOwner"/>  
            </td>
            <td class="table_td td_color">
                共有情况
            </td>
            <td class="table_td">
              <DicSelect dictType = "共有情况" :dictValue="dataForm.houseDTO.ownedSituation" v-on:dictValue="dataForm.houseDTO.ownedSituation = $event"/>
            </td>
            <td class="table_td td_color">
                 建筑面积
            </td>
            <td class="table_td">
              <el-input  v-model="dataForm.houseDTO.areaTotal"/>  
            </td>
            <td class="table_td td_color">
                 房龄
            </td>
            <td class="table_td">
              <el-input  v-model="dataForm.houseDTO.houseAge"/>  
            </td>
           
          </tr>
          
          <!--第二行行-->
          <tr>
         
            <td class="table_td td_color">
                坐落
            </td>
            <td colspan="3" class="table_td">
              <el-input  v-model="dataForm.houseDTO.located"/>  
            </td>
            <td class="table_td td_color">
                现使用情况
            </td>
            <td colspan="1" class="table_td">
              <DicSelect dictType = "现使用情况" :dictValue="dataForm.houseDTO.nowUsage" v-on:dictValue="dataForm.houseDTO.nowUsage = $event"/>
              <!-- <el-input  v-model="dataForm.houseDTO.nowUsage"/>   -->
            </td>
            <td class="table_td td_color">
                 产权获取方式
            </td>
            <td class="table_td">
                <DicSelect dictType = "获取方式" :dictValue="dataForm.houseDTO.accessType" v-on:dictValue="dataForm.houseDTO.accessType = $event"/>
            </td>
           
          </tr>
          
          <!--第三行-->
          <tr>
            <td colspan="2" class="table_td td_color">
                权利(土地)性质
            </td>
            <td class="table_td">
              <DicSelect dictType = "土地权利性质" :dictValue="dataForm.houseDTO.landNature" v-on:dictValue="dataForm.houseDTO.landNature = $event"/>
            </td>
            <td class="table_td td_color">
                权利(房产)性质
            </td>
            <td colspan="1" class="table_td">
                <el-input v-model="dataForm.houseDTO.houseNature"/>
            </td>
            <td class="table_td td_color">
                 抵押现状
            </td>
            <td colspan="2" class="table_td">
                <DicSelect dictType = "抵押物现状" :dictValue="dataForm.houseDTO.currentSituation" v-on:dictValue="dataForm.houseDTO.currentSituation = $event"/>
            </td>
          </tr>
          
          <!--第四行-->
          <tr v-for="(item,index) in dataForm.houseDTO.houseHistries">
            <td class="table_td td_color">
                {{getValue(index+1)}}押机构
            </td>
            <td colspan="2" class="table_td">
                <el-input v-model="item.borrowerOrg"/>
            </td>
            <td class="table_td td_color">
                {{getValue(index+1)}}押期限
            </td>
            <td colspan="2" class="table_td">
                <el-input v-model="item.deadline"/>
            </td>
            <td class="table_td td_color">
                 {{getValue(index+1)}}押余额
            </td>
            <td colspan="2" class="table_td">
                <el-input v-model="item.remainCapital"/>
            </td>
          </tr>
          
          <!--第五行-->
          
          <!--第六行-->
          <tr>
            <td colspan="2" class="table_td td_color">
                房产评估总价(蓝海APP)
            </td>
            <td class="table_td">
                <el-input v-model="dataForm.houseDTO.lanhaiEvaluationPrice"/>
            </td>
            <td colspan="2" class="table_td td_color">
                房产评估总价(终审)
            </td>
            <td class="table_td">
                <el-input v-model="dataForm.houseDTO.finalReviewEvaluationPrice"/>
            </td>
            <td class="table_td td_color">
                 房产剩余价值
            </td>
            <td colspan="2" class="table_td">
                <el-input v-model="dataForm.houseDTO.remainValue"/>
            </td>
          </tr>
          
          <!--第七行-->
          <tr>
            <td class="table_td">
                
            </td>
            <td  class="table_td td_color">
                查询时间
            </td>
            <td class="table_td">
                <el-input v-model="dataForm.houseDTO.queryTime"/>
            </td>
            <td  class="table_td td_color">
                是否白户
            </td>
            <td class="table_td">
                <el-select v-model="dataForm.houseDTO.shiratoStatus" placeholder="请选择">
                  <el-option label="是" :value="1"></el-option>
                  <el-option label="否" :value="0"></el-option>
                </el-select>
                <!-- <el-input v-model="dataForm.houseDTO.shiratoStatus"/> -->
            </td>
            <td class="table_td td_color"  style="font-size:13px;">
                 查询时间(配偶)
            </td>
            <td colspan="1" class="table_td">
                <el-input v-model="dataForm.houseDTO.queryTimeSpouse"/>
            </td>
            <td class="table_td td_color" style="font-size:13px;">
                 是否白户(配偶)
            </td>
            <td colspan="1" class="table_td">
                  <el-select v-model="dataForm.houseDTO.shiratoStatusSpouse" placeholder="请选择">
                  <el-option label="是" :value="1"></el-option>
                  <el-option label="否" :value="0"></el-option>
                </el-select>
                <!-- <el-input v-model="dataForm.houseDTO.shiratoStatusSpouse"/> -->
            </td>
          </tr>
          
          <!--第八行  征信情况-->
          <tr>
            <td rowspan="3" class="table_td td_color">
                征信情况
            </td>
            <td class="table_td td_color">
                贷款描述
            </td>
            <td colspan="7" class="table_td">
                <el-input type="textarea"  :rows="5" v-model="dataForm.creditDTO.loanDesc"/>
            </td>
          </tr>
          <!--第九行  -->
          <tr>
            <td class="table_td td_color">
                信用卡描述
            </td>
            <td colspan="7" class="table_td">
                <el-input type="textarea"  :rows="5" v-model="dataForm.creditDTO.creditCardDesc"/>
            </td>
          </tr>
          <!--第十行  -->
          <tr>
            <td class="table_td td_color">
                其他
            </td>
            <td colspan="7" class="table_td">
                <el-input type="textarea"  :rows="5" v-model="dataForm.creditDTO.otherDesc"/>
            </td>
          </tr>
          <!--第11行  审查信息-->
          <tr class="tr_height">
            <td class="table_td td_color">
                借款用途（详细描述）
            </td>
            <td colspan="8" class="table_td">
                <el-input type="textarea" :rows="5"   v-model="dataForm.reviewInfoDTO.borrowUse"/>
            </td>
          </tr>
          <!--第12行  -->
          <tr class="tr_height">
            <td class="table_td td_color" >
                客户综合情况及风控意见
            </td>
            <td colspan="8" class="table_td">
                <el-input type="textarea"  :rows="5" v-model="dataForm.reviewInfoDTO.customerOpinion"/>
            </td>
          </tr>
          <!--第13行  -->
          <tr>
            <td class="table_td td_color">
                担保措施
            </td>
            <td colspan="8" class="table_td">
                <el-input type="textarea"  :rows="5" v-model="dataForm.reviewInfoDTO.guaranteeMeasures"/>
            </td>
          </tr>
          <!--第14行  -->
<!--           <tr>
            <td class="table_td td_color">
                国厚终审意见
            </td>
            <td class="table_td td_color">
                审批金额
            </td>
            <td colspan="2" class="table_td">
                <el-input v-model="dataForm.reviewInfoDTO.approveAmount"/>                
            </td>
            <td class="table_td td_color">
                年利率
            </td>
            <td class="table_td">
                <el-input v-model="dataForm.reviewInfoDTO.annualInterestRate"/>                    
            </td>
            <td class="table_td td_color">
                还款方式
            </td>
            <td colspan="2" class="table_td">
          <DicSelect dictType = "还款方式" :dictValue="dataForm.reviewInfoDTO.repayMethod" v-on:dictValue="dataForm.reviewInfoDTO.repayMethod=$event"/>                
            </td>
          </tr> -->
          <!--第15行  -->
          <tr>
            <td class="table_td td_color">
                审查员
            </td>
            <td colspan="3" class="table_td">
                <el-input v-model="dataForm.reviewInfoDTO.examiner"/>                
            </td>
            <td class="table_td td_color">
                调查员
            </td>
            <td class="table_td">
                <el-input v-model="dataForm.reviewInfoDTO.investigator"/>                     
            </td>
            <td class="table_td td_color">
                审批人
            </td>
            <td colspan="2" class="table_td">
                <el-input v-model="dataForm.reviewInfoDTO.approvePerson"/>                    
            </td>
          </tr>
          <!--第16行  -->
          <tr>
            <td class="table_td td_color">
                合同专员
            </td>
            <td colspan="3" class="table_td">
                <el-input v-model="dataForm.reviewInfoDTO.contractSpecialist"/>                 
            </td>
            <td class="table_td td_color">
                办押专员
            </td>
            <td class="table_td">
                 <el-input v-model="dataForm.reviewInfoDTO.detentionSpecialist"/>               
            </td>
            <td class="table_td td_color">
                档案管理
            </td>
            <td colspan="2" class="table_td">
                 <el-input v-model="dataForm.reviewInfoDTO.fileManagement"/>                  
            </td>
          </tr>
        
        </tbody>
      </table>
      </el-form>
        <div style="width:400px;margin:0 auto;margin-top:5%;">
          <el-button v-permission="'system:check-opinion:print'"  type="primary" @click="exportData" style="width:150px;height:40px;">打印</el-button>
          <el-button v-if="operationLook === undefined " v-permission="'system:check-opinion:edit'"  type="warning" @click="createData" style="width:150px;height:40px;">保存</el-button>
        </div>
    </div>


    
 

</template>

<script>
import { findByProjectId,editReview,exportReview } from '@/api/review'
import DicSelect from '@/components/select'
  export default {
    components: { DicSelect },
    props:{
      changeValue: undefined,
      taskId: undefined,
      projectId: undefined,
      operationLook: undefined
    },
    data () {
      return {
         headData: "",
         dataForm:{
         }
      }
    },
    created(){
      this.findByProjectId()
    },
    methods: {
      findByProjectId() {
      findByProjectId({projectId:this.projectId})
        .then(response => {
          if(response.data != undefined ) {
            this.dataForm = response.data
            if(this.dataForm.houseDTO.located == '' || this.dataForm.houseDTO.located == undefined ) {
              this.dataForm.houseDTO.located = this.dataForm.houseDTO.addressDetail
            }
          }
        })
        .catch(() => {
          this.dataForm = undefined
        })
    },
    getValue(index){
      if(index == 1) {
        return "一";
      }
      if(index == 2) {
        return "二";
      }
    },
      createData(){
        this.dataForm.projectId = this.projectId
        this.dataForm.taskId = this.taskId
        this.dataForm.creditDTO.projectId = this.projectId
        this.dataForm.reviewInfoDTO.projectId = this.projectId
        editReview(this.dataForm)
            .then(response => {
              this.findByProjectId()
              this.$notify.success({
                title: '成功',
                message: '保存成功'
              })
            })
            .catch(response => {
              this.$notify.error({
                title: '失败',
                message: response.data.message
              })
            })
    },
    exportData() {

        exportReview({projectId: this.projectId})
            .then((res) => {
              this.$notify.success({
                title: '成功',
                message: '导出成功'
              })
              const content = res
            const blob = new Blob([content])
            const fileName = '审查信息.xlsx'
            if ('download' in document.createElement('a')) { // 非IE下载
              const elink = document.createElement('a')
              elink.download = fileName
              elink.style.display = 'none'
              elink.href = URL.createObjectURL(blob)
              document.body.appendChild(elink)
              elink.click()
              URL.revokeObjectURL(elink.href) // 释放URL 对象
              document.body.removeChild(elink)
            } else { // IE10+下载
              navigator.msSaveBlob(blob, fileName)
            }
            })
            .catch(response => {
              console.log(response)
              this.$notify.error({
                title: '失败',
                message: response.data.message
              })
            })
    },
    }
  }
</script>

<style>


.table_review .el-input__inner{
  height:52px;
  line-height: 55px;
  border:0px solid;
}

.table_review .el-textarea__inner{
  /* height:52px;
  line-height: 55px; */
  border:0px solid;
}

.table_review {
  background-color: #fff;
  width: 100%;
  font-size: 14px;
}
.table_title{
  background-color: #fff;
  border-top: 1px solid #c7c7c7;
  border-right: 1px solid #c7c7c7;
  border-left: 1px solid #c7c7c7;
  width: 100%;
  background-color: #fff;
  text-align: center;
  line-height: 50px;
}
.table_wrap{
  border-collapse: collapse;
  border-spacing: 0px;
  width: 100%;

}

.table_td {
  text-align: center;
  line-height: 50px;  
  min-width: 90px;
  border: 1px solid #c7c7c7;
}
.td_color{
  background-color: #f4f4f4;
}

.tr_height{
  height:100%;
  line-height: 100%;
}
</style>